package com.displayCongress;

import android.content.SharedPreferences;

import java.io.IOException;

/**
 * @author wouter
 *         Date: 1/8/13
 *         Time: 11:07 AM
 */
public class ConnectionThread implements Runnable {

    private SharedPreferences settings;

    public ConnectionThread(SharedPreferences settings) {
        this.settings = settings;
    }

    @Override
    public void run() {
        try {
            String serverIp = settings.getString("serverIp", "notSet");

            if (!serverIp.equals("notSet")) {

                MainActivity.congressSocket = new CongressSocket(serverIp, 11000);

                String username = settings.getString("serverUsername", "notSet");
                String password = settings.getString("serverPasswd", "notSet");

                MainActivity.congressSocket.login(username, password);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
